package com.tanhua.houtai.service;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tanhua.houtai.mapper.AnalyByDayMapper;
import com.tanhua.houtai.pojo.AnalyByData;
import com.tanhua.houtai.vo.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class AnalyByDayService {

    @Autowired
    private AnalyByDayMapper analyByDayMapper;

//     @Autowired
//    public PageResult1<AnalysisByDay> queryDateStatisticsList;

    public PageResult queryDateStatisticsList(String datebegin, String dateend, Integer page, Integer pagesize) {
        PageResult pageResult = new PageResult();
        pageResult.setPage(page);
        pageResult.setPagesize(pagesize);

        QueryWrapper<AnalyByData> queryWrapper = new QueryWrapper<>();
        //QueryWrapper<AnalyByDayVo> queryWrapper = new QueryWrapper<>();
        // 判断请求的参数信息是否为空
        if (!(null == datebegin && null == dateend)) {
            // 如果查询条件的开始时间和结束时间不为空,将参数作为条件进行查询
            queryWrapper.between("record_date", datebegin, dateend);
        }

        // 调用dubbo查询数据
        // 将所有数据按照记录的时间进行倒叙排序
        queryWrapper.orderByDesc("record_date");
        List<AnalyByData> tongJis = analyByDayMapper.selectList(queryWrapper);

        pageResult.setItems(tongJis);

        return pageResult;
    }

}
